package com.itlong.cloud.operate.resource;

import com.itlong.cloud.POJO.DTO.operate.OperateUpdateInfoGetPageDTO;
import com.itlong.cloud.POJO.DTO.operate.OperateUpdateUpdateInfoDTO;
import com.itlong.cloud.POJO.PO.OperationSpecialLogPO;
import com.itlong.cloud.POJO.VO.operate.DeviceTypeDefineVO;
import com.itlong.cloud.POJO.VO.operate.OperateUpdateDetailVO;
import com.itlong.cloud.POJO.VO.operate.OperateUpdateInfoVO;
import com.itlong.cloud.equip.operate.IOperatePackageServiceClient;
import com.itlong.cloud.operate.service.IOperatePackageService;
import com.itlong.cloud.operate.service.OperationSpecialLogService;
import com.itlong.cloud.utils.page.Page;
import org.slf4j.Logger;import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <desc>
 *     运营-固件升级-安装包管理露接口实现类。
 * <desc/>
 *
 * @createDate 2018/08/23.
 */
@RestController
public class OperatePackageServiceResource implements IOperatePackageServiceClient {

    private static final Logger LOG = LoggerFactory.getLogger(OperatePackageServiceResource.class);

    @Autowired
    IOperatePackageService iOperatePackageService;

    @Autowired
    OperationSpecialLogService operationSpecialLogService;
    /**
     * <desc>
     *      分页获取安装包信息。
     * <desc/>
     *
     * @param  operateUpdateInfoGetPageDTO 参数请求对象
     * @return
     * @author Qiang.S
     * @createDate 2018/08/23
     */
    @Override
    @RequestMapping(path = "/operate/upgrade/package/getUpdateInfoPage",method = RequestMethod.POST)
    public Page<OperateUpdateInfoVO> getUpdateInfoPage(@RequestBody OperateUpdateInfoGetPageDTO operateUpdateInfoGetPageDTO) throws Exception{
        return iOperatePackageService.getUpdateInfoPage(operateUpdateInfoGetPageDTO);
     }

    /**
     * <desc>
     *      批量删除安装包信息
     * <desc/>
     *
     * @param updateIds 更新文件编号,逗号分隔
     * @return
     * @author Qiang.S
     * @createDate 2018-08-23
     */
    @Override
    @RequestMapping(path = "/operate/upgrade/package/deleteUpdateInfo",method = RequestMethod.POST)
    public Integer deleteUpdateInfo(@RequestParam("updateIds") String updateIds,@RequestParam("userId") String userId,
                                    @RequestParam("operateFunction") String operateFunction,@RequestParam("operateWay") String operateWay,
                                    @RequestParam("updateNames") String updateNames,@RequestParam("ip") String ip ) throws Exception{
        return iOperatePackageService.deleteUpdateInfo(updateIds, userId,
                operateFunction,operateWay,updateNames,ip);
    }

    /**
     * <desc>
     *      根据名称查询结果
     * <desc/>
     *
     * @param updateName 文件名称
     * @return
     * @author Qiang.S
     * @createDate 2018-08-23
     */
    @Override
    @RequestMapping(path = "/operate/upgrade/package/getUpdateInfoByName",method = RequestMethod.POST)
    public String getUpdateInfoByName(@RequestParam("updateName") String updateName) throws Exception{
        return iOperatePackageService.getUpdateInfoByName(updateName);
    }

    /**
     * <desc>
     *      获取安装包详细信息。
     * <desc/>
     *
     * @param updateId 更新文件编号
     * @return
     * @author Qiang.S
     * @createDate 2018/08/23
     */
    @Override
    @RequestMapping(path = "/operate/upgrade/package/getUpdateDetail",method = RequestMethod.POST)
    public OperateUpdateDetailVO getUpdateDetail(@RequestParam("updateId") String updateId) throws Exception{
        return iOperatePackageService.getUpdateDetail(updateId);
    }

    /**
     * <desc>
     *      安装包信息更新(未更新安装文件时使用)
     * <desc/>
     *
     * @param operateUpdateUpdateInfoDTO 更新安装包信息
     * @return
     * @author Qiang.S
     * @createDate 2018-08-28
     */
    @Override
    @RequestMapping(path = "/operate/upgrade/package/updateUpdateInfo",method = RequestMethod.POST)
    public Integer updateUpdateInfo(@RequestBody OperateUpdateUpdateInfoDTO operateUpdateUpdateInfoDTO) throws Exception{
        return iOperatePackageService.updateUpdateInfo(operateUpdateUpdateInfoDTO);
    }
   
   /**
   *<desc>
   * @Description
   *</desc>
   *
   * @Author  chengshican
   * @Date   2020-11-11 16:01
   * @Param  
   * @Return      
   * @Exception   
   * 
   */
    @Override
    @RequestMapping(path = "/operate/upgrade/package/getOperationSpecialLogList" ,method = RequestMethod.POST)
    public  Page<OperationSpecialLogPO> getOperationSpecialLogList(@RequestParam("updateId") String outerId,
                                                                   @RequestParam(value = "pageSize",required = false) String pageSize,
                                                                   @RequestParam(value = "currentPage",required = false) String currentPage,
                                                                   @RequestParam(value = "orderColumn",required = false) String orderColumn,
                                                                   @RequestParam(value = "orderRule",required = false) String orderRule) throws Exception{
        return operationSpecialLogService.getOperationSpecialLog(outerId,pageSize,currentPage,orderColumn,orderRule);
    }

    
    /**
    *<desc>
    * @Description
    *</desc>
    *
    * @Author  chengshican
    * @Date   2020-11-11 16:01
    * @Param  
    * @Return      
    * @Exception   
    * 
    */
    @RequestMapping(path = "/operate/upgrade/package/getOperationSpecialLogByLogId" ,method = RequestMethod.POST)
    @Override
    public OperationSpecialLogPO getOperationSpecialLogByLogId(@RequestParam("LogId") String LogId) throws Exception {
        return operationSpecialLogService.getOperationSpecialLogByLogId(LogId);
    }

    
    
    /**
    *<desc>
    * @Description
    *</desc>
    *
    * @Author  chengshican
    * @Date   2020-11-11 16:01
    * @Param  
    * @Return      
    * @Exception   
    * 
    */
    @Override
    @RequestMapping(path = "/operate/upgrade/package/getProductCodeByDeviceType" ,method = RequestMethod.POST)
    public List<DeviceTypeDefineVO> getProductCodeByDeviceType (@RequestParam("deviceTypes") String deviceTypes)throws Exception{
      return  iOperatePackageService.getProductCodeByDeviceType(deviceTypes);
    }
}
